<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateCollegeTrainingOrderUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('college_training_order_users', function (Blueprint $table) {
            $table->id();
            $table->char('examNo', 20)->default('')->comment('测评单号');
            $table->unsignedInteger('userId')->default(0)->comment('rms userId');
            $table->unsignedInteger('trainingOrderId')->default(0)->comment('培训单id');
            $table->unsignedInteger('cruiseOrderId')->default(0)->comment('试卷id');
            $table->unsignedInteger('examTotalScore')->default(0)->comment('试卷满分');
            $table->unsignedInteger('examActualScore')->default(0)->comment('试卷实际得分');
            $table->unsignedInteger('practiceScore')->default(0)->comment('实操分数');
            $table->unsignedInteger('examEndTime')->default(0)->comment('考试截止时间');
            $table->unsignedInteger('examQuestionNum')->default(0)->comment('考题数量');

            $table->tinyInteger('examResult')->default(0)->comment('理论考试是否通过 0初始化 1通过 2不通过 3已关闭/超时');
            $table->tinyInteger('practiceResult')->default(0)->comment('实操考试是否通过 0初始化 1通过 2不通过 3已关闭');
            $table->tinyInteger('finalResult')->default(0)->comment('合计结果 0初始化 1通过 2不通过 3已关闭');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->tinyInteger('isDeleted')->default(0)->comment('');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '商学院 - 培训单关联用户表';

            $table->index('trainingOrderId', 'idx_trainingOrderId');
            $table->index('userId', 'idx_userId');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('college_training_order_users');
    }
}
